<template>
  <div class="reports">
    <div class="reports_header">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>订单管理</el-breadcrumb-item>
        <el-breadcrumb-item>订单列表</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="reports_list_box">
      <div class="reports_list_box_box">
        <div id="main" style="width: 750px; height: 400px"></div>
      </div>
    </div>
  </div>
</template>

<script>
import { getreports } from "@/api/reports.js";
import * as echarts from "echarts";
import _ from "lodash";

export default {
  data() {
    return {
      options: {
        title: {
          text: "用户来源",
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#E9EEF3",
            },
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
            boundaryGap: false,
          },
        ],
        yAxis: [
          {
            type: "value",
          },
        ],
      },
    };
  },
  async mounted() {
    var myChart = echarts.init(document.getElementById("main"));
    const res = await getreports();
    if (res.meta.status !== 200)
      return this.$message.error("获取折线图数据失败！");
    const result = _.merge(res.data, this.options);
    myChart.setOption(result);
  },
  methods: {},
  components: {},
};
</script>

<style lang='scss' scoped>
.reports {
  width: 100%;
  height: 100%;
  background: #eee;
  .reports_header {
    width: 100%;
    height: 80px;
    // line-height: 80px;
    padding-top: 30px;
    padding-left: 40px;
  }
  .reports_list_box {
    width: 100%;
    height: calc(100% - 80px);
    .reports_list_box_box {
      width: 95%;
      height: 100%;
      background: #fff;
      margin: 0 auto;
    }
  }
}
</style>
